﻿using System;
using System.Collections.Generic;

namespace IllicitOnion.LinqDimensions
{
	public class CartesianProductEnumerable<T0, T1> : CompoundEnumerable<T0, T1>
	{
		public CartesianProductEnumerable(IEnumerable<T0> t0s, IEnumerable<T1> t1s) : base(t0s, t1s)
		{
		}

		public override void ForEach(Action<T0, T1> action)
		{
			foreach (var t0 in m_Left)
			{
				foreach (var t1 in m_Right)
				{
					action(t0, t1);
				}
			}
		}

		public override IEnumerable<T0, T1, T2> And<T2>(IEnumerable<T2> t2s)
		{
			return new CompoundEnumerable<T0, T1, T2>(this, t2s);
		}
	}
}
